package com.zzl.bonds.ticket.dto.finance;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.zzl.apidoc.annotation.ApidocModel;
import com.zzl.apidoc.annotation.ApidocModelProperty;
import com.zzl.apidoc.constants.RequiredType;
import com.zzl.bonds.ticket.entity.BusinessContractEntity;
import com.zzl.bonds.ticket.entity.TicketDataEntity;
import com.zzl.general.common.utils.DoubleSerialize;
import com.zzl.general.common.utils.DoubleToPercentSerialize;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 融资申请单
 *
 * @author gull
 * @date 2022-02-24 13:53:42
 */
@Data
@ApidocModel
public class TicketFinanceDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private String id;

    @ApidocModelProperty(description = "凭证编号")
    private String ticketNo;
    @ApidocModelProperty(description = "金融机构名称")
    private String instinctyName;
    @ApidocModelProperty(description = "入账银行账号")
    private String financeDepositBank;
    @ApidocModelProperty(description = "开户行")
    private String financeDepositBankName;

    public String getFinanceDepositBank() {
        if (!StringUtils.isBlank(financeDepositBankName)) {
            return financeDepositBankName + "-" + financeDepositBank;
        }
        return financeDepositBank;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApidocModelProperty(description = "申请日期", validate = "yyyy-MM-dd")
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApidocModelProperty(description = "预计到账时间", validate = "yyyy-MM-dd", required = RequiredType.TRUE, example = "2022-8-15")
    private Date estimateDisbursementDate;
    @NotNull(message = "付息方式不能为空")
    @ApidocModelProperty(description = "付息方式 ：1 融资方付息（默认）2 核心企业付息", example = "1", required = RequiredType.TRUE)
    private Integer paymentMode;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "转让金额", required = RequiredType.TRUE, example = "1")
    private Double financeAmount;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "预计到账", required = RequiredType.TRUE, example = "1000")
    private Double estimateLoanAmount;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "融资成本", required = RequiredType.TRUE, example = "25")
    private Double financingCost;
    @JsonSerialize(using = DoubleToPercentSerialize.class)
    @ApidocModelProperty(description = "融资利率", required = RequiredType.TRUE, example = "0.15")
    private Double annualizedInterestRate;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "平台服务费用", required = RequiredType.TRUE, example = "10")
    private Double serviceChage;
    @JsonSerialize(using = DoubleToPercentSerialize.class)
    @ApidocModelProperty(description = "平台服务费率", required = RequiredType.TRUE, example = "0.1")
    private Double platServiceRate;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "融资利息", required = RequiredType.TRUE, example = "15")
    private Double annualizedInterest;
    @ApidocModelProperty(description = "合同编号")
    private String contractNo;

    @ApidocModelProperty(description = "凭证资料")
    private List<TicketDataEntity> proofList;
    @ApidocModelProperty(description = "发票信息")
    private List<TicketDataEntity> invoiceList;
    @ApidocModelProperty(description = "签署资料")
    List<BusinessContractEntity> protocolList;
    @ApidocModelProperty(description = "凭证状态 1：融资待复核 2、融资已复核 3、平台待复核 4、平台已复核 5、待放款")
    private String ticketStatusName;

    @JsonIgnore
    private Integer ticketStatus;
    @ApidocModelProperty(description = "处理状态信息悬浮")
    private String handStatusInfo;
    @ApidocModelProperty(description = "处理状态")
    private String handStatus;
    @ApidocModelProperty(description = "处理进度，如20")
    private Integer handProgress;
}
